
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>ssm整合activiti - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>ssm整合activiti - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">在搭建Activiti项目时，根据文档，activiti-context.xml配置文件应该从哪个路径复制？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">根据文档，activiti-context.xml配置文件应从 `activiti-5.13\wars\activiti-rest\WEB-INF\classes` 路径复制到工程中。</div>
          </div>
          <div class="card-source">来源: 配置文件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">除了Activiti自身的核心库外，文档还明确指出了需要额外导入哪三个具体的jar包？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">除了Activiti的核心库，还需要导入三个额外的包：`slf4j-api-1.5.8.jar`, `slf4j-log4j12.jar`, 和 `joda-time-2.1.jar`。</div>
          </div>
          <div class="card-source">来源: jar包</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Spring配置文件中，Activiti的各项服务（如repositoryService, runtimeService, taskService）是如何被创建并注入到Spring容器中的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">这些服务是通过将 `processEngine` bean作为工厂bean（factory-bean），并分别调用其对应的工厂方法（factory-method），例如 `getRepositoryService`、`getRuntimeService`等来创建的。</div>
          </div>
          <div class="card-source">来源: 配置文件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在“启动流程实例”的代码中，`runtimeService.startProcessInstanceByKey`方法被调用来启动流程，它接收了哪三个关键参数？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该方法接收了三个参数：1. 流程定义的Key (`processKey`)；2. 业务主键 (`bk`)；3. 流程变量的Map集合 (`variableMap`)。</div>
          </div>
          <div class="card-source">来源: 启动流程实例</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">根据文档中的代码示例，业务主键（businessKey）是如何生成的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">业务主键是通过将业务对象的类名（作为`processKey`）、一个点（"."）和业务对象的ID进行拼接生成的，格式为 `processKey + "." + workFlowBean.getId()`。</div>
          </div>
          <div class="card-source">来源: 启动流程实例</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何通过一个任务ID（taskId）来查询关联的业务对象（LeaveBill）？请描述代码中的实现步骤。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">1. 使用`taskService`通过任务ID查询到`processInstanceId`。2. 使用`runtimeService`通过`processInstanceId`查询到`ProcessInstance`对象。3. 从`ProcessInstance`对象中获取`businessKey`。4. 对`businessKey`按点（"."）进行分割，获取业务对象的ID。5. 使用该ID查询并返回`LeaveBill`对象。</div>
          </div>
          <div class="card-source">来源: 查询请假单对象</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">文档中展示了两种获取流程实例批注信息（Comments）的方法，它们分别是如何实现的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">第一种方法是通过`taskId`，先用`taskService`查询到`processInstanceId`，再调用`taskService.getProcessInstanceComments(processInstanceId)`。第二种方法是直接使用自定义的业务主键（key），通过`historyService`查询到历史流程实例，获取其ID，再调用`taskService.getProcessInstanceComments()`。</div>
          </div>
          <div class="card-source">来源: 获取批注信息, 根据自定义key查询批注信息</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在“获取连线信息”部分，代码是如何获取当前活动节点所有出口（outgoing transitions）的名称的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过`repositoryService`获取流程定义实体(`ProcessDefinitionEntity`)，然后找到当前活动节点(`ActivityImpl`)，再调用其`getOutgoingTransitions()`方法获取所有出口连线列表，最后遍历列表并获取每个连线的`name`属性值。</div>
          </div>
          <div class="card-source">来源: 获取连线信息</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在“完成我的任务”的代码中，添加批注（Comment）和完成任务（Complete Task）的操作顺序是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">代码中先调用`taskService.addComment()`方法添加批注，之后再调用`taskService.complete()`方法来完成任务。</div>
          </div>
          <div class="card-source">来源: 完成我的任务</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">当任务完成后，代码是如何判断整个流程实例是否已经结束，并据此更新业务对象（LeaveBill）的状态的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在调用`taskService.complete()`之后，代码会立即使用`runtimeService`根据`processInstanceId`查询流程实例。如果查询结果为null，说明流程实例已结束，此时会更新请假单（LeaveBill）的状态为2。</div>
          </div>
          <div class="card-source">来源: 完成我的任务</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在任务监听器中设置下一个处理人的逻辑是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过`RequestContextHolder`获取HTTP会话，从中得到当前登录用户。然后，通过`IUserService`查询到当前用户的上级经理。最后，使用`delegateTask.setAssignee()`方法将任务的办理人设置为该上级经理的中文名。</div>
          </div>
          <div class="card-source">来源: 设置下一个处理人</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何根据当前登录用户的身份来查询分配给他的任务列表，并按创建时间降序排序？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过调用 `taskService.createTaskQuery().orderByTaskCreateTime().desc().taskAssignee(user.getName()).list()` 方法。其中 `user.getName()` 用于指定任务的办理人。</div>
          </div>
          <div class="card-source">来源: 查询我的任务</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
